package com.woorigil.social.domain.qna.parser;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.woorigil.social.domain.ProviderCode;

@Component
public class QnaParserFactory {
	@Autowired
	private List<QnaParser> qnaParsers;

	public QnaParser get(ProviderCode providerCode) {
		if (qnaParsers != null) {
			for (QnaParser parser : qnaParsers) {
				if (parser.getProviderCode() == providerCode) {
					return parser;
				}
			}
		}
		throw new IllegalArgumentException("invalid provider code");
	}
}
